{%- macro book_list(data,currentId) %}
    {% for nodeId,item in data.toc %}
        {% if loop.first %}
        <ul class="book-toc toc">
        {% endif %}
        <li id="book-node-id-{{ nodeId }}">

            <a{% if currentId == nodeId %} class="active"{% endif %} href="{{ url(['for':'node','contentModel':item.contentModel,'id':nodeId]) }}">{{ item.title }}</a>
            {% if is_array(item) AND item.son is defined AND item.son is not empty %}
                {{ book_list(item.son,currentId) }}
            {% endif %}

        </li>
        {% if loop.last %}
        </ul>
        {% endif %}
    {% endfor %}
{%- endmacro %}

<h2 class="book-toc-title">
    <a href="{{ url(['for':'node','contentModel':bookNode.contentModel,'id':bookNode.getId()]) }}">
        <i aria-hidden="true" class="fa fa-book"></i>{{ bookNode.title }}
    </a>
</h2>
{% if data %}
    {{ book_list(data,currentId) }}
{% endif %}